package com.example.springcloudconfig.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.crypto.codec.Hex;
import org.springframework.security.crypto.codec.Utf8;
import org.springframework.security.crypto.encrypt.BytesEncryptor;
import org.springframework.security.crypto.encrypt.BouncyCastleAesCbcBytesEncryptor;
import org.springframework.security.rsa.crypto.RsaRawEncryptor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

/**
 * @author: scout.du
 * @date: 2023/02/19 17:03
 **/

@RestController
public class HelloController {

    @Value("${connectivity.appKey}")
    private String appKey;

    @Value("${connectivity.redis}")
    private String redis;



    @PostConstruct
    public void init(){
        System.out.println(appKey);
        System.out.println(redis);
    }


    @GetMapping("/hello")
    @ResponseBody
    public Map hello(){
        Map<String,String> map = new HashMap<>();
        map.put("appKey",appKey);
//        map.put("appSecret",appSecret);
        map.put("redis",redis);

//        BytesEncryptor encryptor = new AesBytesEncryptor();
//        String explorerRw = new String(Hex.encode(encryptor.encrypt(Utf8.encode("cost_explorer_rw"))));
        return map;
    }

    /*@GetMapping("/getPass")
    public String getPass(){
        return password;
    }*/
}
